package com.china08.yxyapi.api.manage.sch.office.cookbook;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.entity.mg.cookbook.CookBook;
import com.china08.yxyapi.repository.mg.cookbook.YxySchManageCookbookRepository;
import com.china08.yxyapi.security.profile.YxyProfile;

/**
 * 初始化每周食谱
 * 
 */
@CrossOrigin
@RestController
public class YxySchManagerCookbookDelController extends YxyApiBaseController {

    @Autowired
    private YxySchManageCookbookRepository yxySchManageCookbookRepository;

    @RequestMapping(value = "/api_yw/manage/sch/office/cookbook/del", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public void precess(HttpServletRequest request, HttpServletResponse response) {
        YxyProfile profile = getProfile(request, response);
        List<CookBook> ck = yxySchManageCookbookRepository.findBySchoolId(profile.getSchoolId());
        for (CookBook cookBook : ck) {
            yxySchManageCookbookRepository.delete(cookBook);
        }
    }
}
